package com.anjubao.parking.municipal.parkinglot.controller;

import com.anjubao.parking.municipal.common.dto.ApiResult;
import com.anjubao.parking.municipal.parkinglot.dto.ParkingLotMonitorGuidanceResDto;
import com.anjubao.parking.municipal.parkinglot.dto.ParkingLotMonitorResDto;
import com.anjubao.parking.municipal.parkinglot.service.ParkingLotDeviceMonitorService;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 设备运行状况统计controller
 * @author anjubao
 */
@RestController
@Api(value = "ParkingLotMonitorController", tags = {"设备运行状况统计接口"})
@RequestMapping("/monitor")
public class ParkingLotDeviceMonitorController {

    @Autowired
    private ParkingLotDeviceMonitorService parkingLotDeviceMonitorService;
    private static final Logger logger = LoggerFactory.getLogger(ParkingLotDeviceMonitorController.class);

    /**
     * 设备运行状况统计
     * @param cityId
     * @return
     */
    @ApiOperation(value = "统计设备运行状况接口", notes = "设备运行状况统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityId", value = "城市id", required = true, dataType = "int"),
    })
    @ApiResponses(value = {
            @ApiResponse(code = 5000, message = "操作失败")
    })
    @GetMapping("")
    public ApiResult<List<ParkingLotMonitorResDto>> selectDevices(Integer cityId) {
        logger.info("统计设备运行状况 {} ",cityId);
        List<ParkingLotMonitorResDto> parkingLotDeviceResDtos = parkingLotDeviceMonitorService.selectDevices(cityId);
        return ApiResult.success(parkingLotDeviceResDtos);
    }

    /**
     * 诱导屏运行状况统计
     * @param cityId
     * @return
     */
    @ApiOperation(value = "统计诱导屏运行状况接口", notes = "诱导屏运行状况统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityId", value = "城市id", required = true, dataType = "int"),
    })
    @ApiResponses(value = {
            @ApiResponse(code = 5000, message = "操作失败")
    })
    @GetMapping("/devices/guidance-screens")
    public ApiResult<List<ParkingLotMonitorGuidanceResDto>> selectGuidanceScreen(Integer cityId) {
        logger.info("统计诱导屏运行状况 {} ",cityId);
        List<ParkingLotMonitorGuidanceResDto> parkingLotDeviceResDtos =parkingLotDeviceMonitorService.selectGuidanceScreen(cityId);
        return ApiResult.success(parkingLotDeviceResDtos);
    }
}
